import 'package:flutter/material.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/bar_util.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/service_controller/feedback_page_controller.dart';
import 'package:xinxuan/utils/color_util.dart';

class FeedbackPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: pageBgColor,
      appBar: AppBarUtil(
        title: '反馈投诉',
        backgroundColor: bgWhiteColor,
      ),
      body: GetBuilder<FeedbackPageController>(
        init: FeedbackPageController(),
        builder: (controller) {
          return ScrollConfigurationCommon(child: ListView(
            children: [
              BarUtil(title: '我要反馈'),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 16.w),
                child: Container(
                  decoration: BoxDecoration(
                    color: bgWhiteColor,
                    borderRadius: BorderRadius.circular(5.w)
                  ),
                  child: Column(
                    children: [
                      Container(
                        padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 14),
                        child: TextField(
                          controller: TextEditingController(text: controller.content.value),
                          decoration: InputDecoration(
                            border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            contentPadding: EdgeInsets.zero,
                            counterText: '',
                            hintText: '请输入反馈信息',
                            hintStyle: TextStyle(
                              fontSize: 14.sp,
                              color: textSubtitleColor,
                            )
                          ),
                          maxLines: 9,
                          maxLength: 190,
                          cursorColor: textBlackColor,
                          style: TextStyle(
                            fontSize: 14.sp,
                            color: textBlackColor
                          ),
                          onChanged: (String value) {
                            controller.content.value = value;
                          },
                        ),
                      ),
                      Container(
                        height:47.h,
                        alignment: Alignment.centerLeft,
                        padding: EdgeInsets.symmetric(horizontal: 16.w),
                        decoration: BoxDecoration(
                          border: Border(
                            top: BorderSide(
                              width: .5,
                              color: lineColor
                            )
                          )
                        ),
                        child: TextField(
                          controller: TextEditingController(text: controller.contact.value),
                          decoration: InputDecoration(
                            border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                            contentPadding: EdgeInsets.zero,
                            counterText: '',
                            hintText: '请留下您的联系方式（QQ、微信、手机号）',
                            hintStyle: TextStyle(
                              fontSize: 14.sp,
                              color: textSubtitleColor,
                            )
                          ),
                          keyboardType: TextInputType.number,
                          cursorColor: textBlackColor,
                          maxLength: 100,
                          style: TextStyle(
                            fontSize: 14.sp,
                            color: textBlackColor
                          ),
                          onChanged: (String value) {
                            controller.contact.value = value;
                          },
                        ),
                      )
                    ],
                  ),
                )
              ),
              Container(
                margin: EdgeInsets.only(top: 47.h),
                padding: EdgeInsets.symmetric(horizontal: 20.w),
                child: ButtonUtil(
                  text: '提交', 
                  fontSize: 16.sp, 
                  borderRadius: 30.w, 
                  height: 36.h, 
                  onTop: () {
                    controller.submitFeedback();
                  }
                ),
              )
            ],
          ));
        },
      ),
    );
  }
}